***** Replication code for Franchino, Fabio, and Camilla Mariotto. “Noncompliance Risk, Asymmetric Power and the Design of Enforcement of the European Economic Governance”. European Union Politics.

***** Online Appendix Section 3.3 Re-categorization of governmental positions test: unsystematic errors
* Preparation stage (you can skip this stage)

* Creation of a initial dataset robtest_pos_FC.dta
version 15
pause on
use conflict_data_FC2.dta, clear

* Select a random sample without replacement of observations
set seed 1234
generate random = runiform()
sort random
* change 44 out of 439 obs (half increases and half decreases)
recode discr_com (1 = 2) (2 = 3) if discr_com!=. in 1/18
recode discr_com (2 = 1) (3 = 2) if discr_com!=. in 14/44
recode discr_cou (1 = 2) (2 = 3) if discr_cou!=. in 1/18
recode discr_cou (2 = 1) (3 = 2) if discr_cou!=. in 14/44
recode discr_nat (1 = 2) (2 = 3) if discr_nat!=. in 1/18
recode discr_nat (2 = 1) (3 = 2) if discr_nat!=. in 14/44
drop random
* Generalized structural equation model: Three-levels, Random intercepts
gsem (discr_com <- c.debt_gdp c.nbi c.nbi#c.debt_gdp i.eurozone i.crisis@0 i.cou_pres c.gov_lr c.gov_eu c.goodEU_net_6 i.comm_s M1[act] M2[act>issue_id], ologit ) ///
	 (discr_cou <- c.debt_gdp c.nbi c.nbi#c.debt_gdp i.eurozone i.crisis@0 i.cou_pres c.gov_lr c.gov_eu c.goodEU_net_6 i.comm_s M1[act] M2[act>issue_id], ologit ) ///
     (discr_nat <- c.debt_gdp                        i.eurozone i.crisis   i.cou_pres c.gov_lr c.gov_eu c.goodEU_net_6 i.comm_s M1[act] M2[act>issue_id], ologit ), vce(robust)  iterate(100) intmethod(mcaghermite)
scalar c = e(converged)
scalar list c		
matrix b1=e(b)		
matrix list b1	
matrix b = c*b1
clear
svmat b
save robtest_pos_FC.dta, replace

* Run the procedure below until you get 1000 observations
* Need to re-run the code below if the model does not converge, until you reach 1000 observations.
* If a model does not converge after 100 iterations, betas are entered as zero

local i = 1
while `i' < 1000 {

version 15
use conflict_data_FC2.dta, clear

************** Mis-categorization of positions	 
* Select a random sample without replacement of observations
generate random = runiform() 
sort random
* change 44 out of 439 obs (half increases and half decreases)
recode discr_com (1 = 2) (2 = 3) if discr_com!=. in 1/18
recode discr_com (2 = 1) (3 = 2) if discr_com!=. in 14/44
recode discr_cou (1 = 2) (2 = 3) if discr_cou!=. in 1/18
recode discr_cou (2 = 1) (3 = 2) if discr_cou!=. in 14/44
recode discr_nat (1 = 2) (2 = 3) if discr_nat!=. in 1/18
recode discr_nat (2 = 1) (3 = 2) if discr_nat!=. in 14/44
drop random

display as text "ITERATION " `i'

* Generalized structural equation model: Three-levels, Random intercepts
gsem (discr_com <- c.debt_gdp c.nbi c.nbi#c.debt_gdp i.eurozone i.crisis@0 i.cou_pres c.gov_lr c.gov_eu c.goodEU_net_6 i.comm_s M1[act] M2[act>issue_id], ologit ) ///
	 (discr_cou <- c.debt_gdp c.nbi c.nbi#c.debt_gdp i.eurozone i.crisis@0 i.cou_pres c.gov_lr c.gov_eu c.goodEU_net_6 i.comm_s M1[act] M2[act>issue_id], ologit ) ///
     (discr_nat <- c.debt_gdp                        i.eurozone i.crisis   i.cou_pres c.gov_lr c.gov_eu c.goodEU_net_6 i.comm_s M1[act] M2[act>issue_id], ologit ), vce(robust)  iterate(100) intmethod(mcaghermite) nolog

scalar c = e(converged)
scalar list c		
matrix b1=e(b)		
matrix list b1	
matrix b = c*b1
clear
svmat b
* pause
append using robtest_pos_FC.dta
drop if b1==b2 & b1==0  /* drop non-converging models */
save robtest_pos_FC.dta, replace

local i = `i' + 1
 
}
